package com.database.mapper;


import com.database.character.UserAccount;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

  //登录
  @Select("select * from useraccount where nickname = #{nickname} and password = #{password}")
  UserAccount getByNicknameAndPassword(UserAccount userAccount);

  //查询所有用户
  @Select("select * from useraccount")
  List<UserAccount> list();

  //根据userId查询用户
  @Select("select * from useraccount where user_id = #{userId}")
  UserAccount getByUid(Integer userId);

  //根据nickname查询用户
  @Select("select * from useraccount where nickname = #{nickname}")
  UserAccount getByNickname(String nickname);

  //删除用户
  @Delete("delete from useraccount where user_id = #{userId}")
  int deleteUserByUid(Integer userId);

  //增加用户
  @Insert("insert into useraccount(nickname, password, user_type, register_time, gender, collect_num, attention_num, focused_num, update_time)" +
  "values (#{nickname}, #{password}, #{userType}, #{registerTime}, #{gender}, #{collectNum}, #{attentionNum}, #{focusedNum}, #{updateTime})")
  int addUser(UserAccount userAccount);

  //修改用户
  int updateUser(UserAccount userAccount);

}
